package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.FlagReport;
import org.nterlearning.datamodel.catalog.model.FlagReportModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the FlagReport service. Represents a row in the &quot;CATALOG_FlagReport&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.FlagReportModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FlagReportImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see FlagReportImpl
 * @see org.nterlearning.datamodel.catalog.model.FlagReport
 * @see org.nterlearning.datamodel.catalog.model.FlagReportModel
 * @generated
 */
public class FlagReportModelImpl extends BaseModelImpl<FlagReport>
    implements FlagReportModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a flag report model instance should use the {@link org.nterlearning.datamodel.catalog.model.FlagReport} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_FlagReport";
    public static final Object[][] TABLE_COLUMNS = {
            { "uuid_", Types.VARCHAR },
            { "flagReportId", Types.BIGINT },
            { "groupId", Types.BIGINT },
            { "companyId", Types.BIGINT },
            { "userId", Types.BIGINT },
            { "classNameId", Types.BIGINT },
            { "classPK", Types.BIGINT },
            { "createDate", Types.TIMESTAMP },
            { "title", Types.VARCHAR },
            { "content", Types.VARCHAR },
            { "flagReason", Types.VARCHAR },
            { "flagComment", Types.VARCHAR },
            { "moderateAction", Types.VARCHAR },
            { "moderatorComment", Types.VARCHAR },
            { "status", Types.INTEGER },
            { "statusByUserId", Types.BIGINT },
            { "statusByUserName", Types.VARCHAR },
            { "statusDate", Types.TIMESTAMP }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_FlagReport (uuid_ VARCHAR(75) null,flagReportId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,classNameId LONG,classPK LONG,createDate DATE null,title VARCHAR(2000) null,content VARCHAR(3999) null,flagReason VARCHAR(75) null,flagComment VARCHAR(3999) null,moderateAction VARCHAR(75) null,moderatorComment VARCHAR(3999) null,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_FlagReport";
    public static final String ORDER_BY_JPQL = " ORDER BY flagReport.flagReportId DESC, flagReport.createDate DESC";
    public static final String ORDER_BY_SQL = " ORDER BY CATALOG_FlagReport.flagReportId DESC, CATALOG_FlagReport.createDate DESC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.FlagReport"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.FlagReport"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.FlagReport"),
            true);
    public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
    public static long CLASSPK_COLUMN_BITMASK = 2L;
    public static long COMPANYID_COLUMN_BITMASK = 4L;
    public static long FLAGREPORTID_COLUMN_BITMASK = 8L;
    public static long GROUPID_COLUMN_BITMASK = 16L;
    public static long UUID_COLUMN_BITMASK = 32L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.FlagReport"));
    private static ClassLoader _classLoader = FlagReport.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            FlagReport.class
        };
    private String _uuid;
    private String _originalUuid;
    private long _flagReportId;
    private long _originalFlagReportId;
    private boolean _setOriginalFlagReportId;
    private long _groupId;
    private long _originalGroupId;
    private boolean _setOriginalGroupId;
    private long _companyId;
    private long _originalCompanyId;
    private boolean _setOriginalCompanyId;
    private long _userId;
    private String _userUuid;
    private long _classNameId;
    private long _originalClassNameId;
    private boolean _setOriginalClassNameId;
    private long _classPK;
    private long _originalClassPK;
    private boolean _setOriginalClassPK;
    private Date _createDate;
    private String _title;
    private String _content;
    private String _flagReason;
    private String _flagComment;
    private String _moderateAction;
    private String _moderatorComment;
    private int _status;
    private long _statusByUserId;
    private String _statusByUserUuid;
    private String _statusByUserName;
    private Date _statusDate;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private FlagReport _escapedModelProxy;

    public FlagReportModelImpl() {
    }

    public long getPrimaryKey() {
        return _flagReportId;
    }

    public void setPrimaryKey(long primaryKey) {
        setFlagReportId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_flagReportId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return FlagReport.class;
    }

    public String getModelClassName() {
        return FlagReport.class.getName();
    }

    public String getUuid() {
        if (_uuid == null) {
            return StringPool.BLANK;
        } else {
            return _uuid;
        }
    }

    public void setUuid(String uuid) {
        if (_originalUuid == null) {
            _originalUuid = _uuid;
        }

        _uuid = uuid;
    }

    public String getOriginalUuid() {
        return GetterUtil.getString(_originalUuid);
    }

    public long getFlagReportId() {
        return _flagReportId;
    }

    public void setFlagReportId(long flagReportId) {
        _columnBitmask = -1L;

        if (!_setOriginalFlagReportId) {
            _setOriginalFlagReportId = true;

            _originalFlagReportId = _flagReportId;
        }

        _flagReportId = flagReportId;
    }

    public long getOriginalFlagReportId() {
        return _originalFlagReportId;
    }

    public long getGroupId() {
        return _groupId;
    }

    public void setGroupId(long groupId) {
        _columnBitmask |= GROUPID_COLUMN_BITMASK;

        if (!_setOriginalGroupId) {
            _setOriginalGroupId = true;

            _originalGroupId = _groupId;
        }

        _groupId = groupId;
    }

    public long getOriginalGroupId() {
        return _originalGroupId;
    }

    public long getCompanyId() {
        return _companyId;
    }

    public void setCompanyId(long companyId) {
        _columnBitmask |= COMPANYID_COLUMN_BITMASK;

        if (!_setOriginalCompanyId) {
            _setOriginalCompanyId = true;

            _originalCompanyId = _companyId;
        }

        _companyId = companyId;
    }

    public long getOriginalCompanyId() {
        return _originalCompanyId;
    }

    public long getUserId() {
        return _userId;
    }

    public void setUserId(long userId) {
        _userId = userId;
    }

    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    public String getClassName() {
        if (getClassNameId() <= 0) {
            return StringPool.BLANK;
        }

        return PortalUtil.getClassName(getClassNameId());
    }

    public long getClassNameId() {
        return _classNameId;
    }

    public void setClassNameId(long classNameId) {
        _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;

        if (!_setOriginalClassNameId) {
            _setOriginalClassNameId = true;

            _originalClassNameId = _classNameId;
        }

        _classNameId = classNameId;
    }

    public long getOriginalClassNameId() {
        return _originalClassNameId;
    }

    public long getClassPK() {
        return _classPK;
    }

    public void setClassPK(long classPK) {
        _columnBitmask |= CLASSPK_COLUMN_BITMASK;

        if (!_setOriginalClassPK) {
            _setOriginalClassPK = true;

            _originalClassPK = _classPK;
        }

        _classPK = classPK;
    }

    public long getOriginalClassPK() {
        return _originalClassPK;
    }

    public Date getCreateDate() {
        return _createDate;
    }

    public void setCreateDate(Date createDate) {
        _columnBitmask = -1L;

        _createDate = createDate;
    }

    public String getTitle() {
        if (_title == null) {
            return StringPool.BLANK;
        } else {
            return _title;
        }
    }

    public void setTitle(String title) {
        _title = title;
    }

    public String getContent() {
        if (_content == null) {
            return StringPool.BLANK;
        } else {
            return _content;
        }
    }

    public void setContent(String content) {
        _content = content;
    }

    public String getFlagReason() {
        if (_flagReason == null) {
            return StringPool.BLANK;
        } else {
            return _flagReason;
        }
    }

    public void setFlagReason(String flagReason) {
        _flagReason = flagReason;
    }

    public String getFlagComment() {
        if (_flagComment == null) {
            return StringPool.BLANK;
        } else {
            return _flagComment;
        }
    }

    public void setFlagComment(String flagComment) {
        _flagComment = flagComment;
    }

    public String getModerateAction() {
        if (_moderateAction == null) {
            return StringPool.BLANK;
        } else {
            return _moderateAction;
        }
    }

    public void setModerateAction(String moderateAction) {
        _moderateAction = moderateAction;
    }

    public String getModeratorComment() {
        if (_moderatorComment == null) {
            return StringPool.BLANK;
        } else {
            return _moderatorComment;
        }
    }

    public void setModeratorComment(String moderatorComment) {
        _moderatorComment = moderatorComment;
    }

    public int getStatus() {
        return _status;
    }

    public void setStatus(int status) {
        _status = status;
    }

    public long getStatusByUserId() {
        return _statusByUserId;
    }

    public void setStatusByUserId(long statusByUserId) {
        _statusByUserId = statusByUserId;
    }

    public String getStatusByUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
            _statusByUserUuid);
    }

    public void setStatusByUserUuid(String statusByUserUuid) {
        _statusByUserUuid = statusByUserUuid;
    }

    public String getStatusByUserName() {
        if (_statusByUserName == null) {
            return StringPool.BLANK;
        } else {
            return _statusByUserName;
        }
    }

    public void setStatusByUserName(String statusByUserName) {
        _statusByUserName = statusByUserName;
    }

    public Date getStatusDate() {
        return _statusDate;
    }

    public void setStatusDate(Date statusDate) {
        _statusDate = statusDate;
    }

    /**
     * @deprecated {@link #isApproved}
     */
    public boolean getApproved() {
        return isApproved();
    }

    public boolean isApproved() {
        if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
            return true;
        } else {
            return false;
        }
    }

    public boolean isDraft() {
        if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
            return true;
        } else {
            return false;
        }
    }

    public boolean isExpired() {
        if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
            return true;
        } else {
            return false;
        }
    }

    public boolean isPending() {
        if (getStatus() == WorkflowConstants.STATUS_PENDING) {
            return true;
        } else {
            return false;
        }
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public FlagReport toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (FlagReport) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
                    FlagReport.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        FlagReportImpl flagReportImpl = new FlagReportImpl();

        flagReportImpl.setUuid(getUuid());
        flagReportImpl.setFlagReportId(getFlagReportId());
        flagReportImpl.setGroupId(getGroupId());
        flagReportImpl.setCompanyId(getCompanyId());
        flagReportImpl.setUserId(getUserId());
        flagReportImpl.setClassNameId(getClassNameId());
        flagReportImpl.setClassPK(getClassPK());
        flagReportImpl.setCreateDate(getCreateDate());
        flagReportImpl.setTitle(getTitle());
        flagReportImpl.setContent(getContent());
        flagReportImpl.setFlagReason(getFlagReason());
        flagReportImpl.setFlagComment(getFlagComment());
        flagReportImpl.setModerateAction(getModerateAction());
        flagReportImpl.setModeratorComment(getModeratorComment());
        flagReportImpl.setStatus(getStatus());
        flagReportImpl.setStatusByUserId(getStatusByUserId());
        flagReportImpl.setStatusByUserName(getStatusByUserName());
        flagReportImpl.setStatusDate(getStatusDate());

        flagReportImpl.resetOriginalValues();

        return flagReportImpl;
    }

    public int compareTo(FlagReport flagReport) {
        int value = 0;

        if (getFlagReportId() < flagReport.getFlagReportId()) {
            value = -1;
        } else if (getFlagReportId() > flagReport.getFlagReportId()) {
            value = 1;
        } else {
            value = 0;
        }

        value = value * -1;

        if (value != 0) {
            return value;
        }

        value = DateUtil.compareTo(getCreateDate(), flagReport.getCreateDate());

        value = value * -1;

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        FlagReport flagReport = null;

        try {
            flagReport = (FlagReport) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = flagReport.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        FlagReportModelImpl flagReportModelImpl = this;

        flagReportModelImpl._originalUuid = flagReportModelImpl._uuid;

        flagReportModelImpl._originalFlagReportId = flagReportModelImpl._flagReportId;

        flagReportModelImpl._setOriginalFlagReportId = false;

        flagReportModelImpl._originalGroupId = flagReportModelImpl._groupId;

        flagReportModelImpl._setOriginalGroupId = false;

        flagReportModelImpl._originalCompanyId = flagReportModelImpl._companyId;

        flagReportModelImpl._setOriginalCompanyId = false;

        flagReportModelImpl._originalClassNameId = flagReportModelImpl._classNameId;

        flagReportModelImpl._setOriginalClassNameId = false;

        flagReportModelImpl._originalClassPK = flagReportModelImpl._classPK;

        flagReportModelImpl._setOriginalClassPK = false;

        flagReportModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<FlagReport> toCacheModel() {
        FlagReportCacheModel flagReportCacheModel = new FlagReportCacheModel();

        flagReportCacheModel.uuid = getUuid();

        String uuid = flagReportCacheModel.uuid;

        if ((uuid != null) && (uuid.length() == 0)) {
            flagReportCacheModel.uuid = null;
        }

        flagReportCacheModel.flagReportId = getFlagReportId();

        flagReportCacheModel.groupId = getGroupId();

        flagReportCacheModel.companyId = getCompanyId();

        flagReportCacheModel.userId = getUserId();

        flagReportCacheModel.classNameId = getClassNameId();

        flagReportCacheModel.classPK = getClassPK();

        Date createDate = getCreateDate();

        if (createDate != null) {
            flagReportCacheModel.createDate = createDate.getTime();
        } else {
            flagReportCacheModel.createDate = Long.MIN_VALUE;
        }

        flagReportCacheModel.title = getTitle();

        String title = flagReportCacheModel.title;

        if ((title != null) && (title.length() == 0)) {
            flagReportCacheModel.title = null;
        }

        flagReportCacheModel.content = getContent();

        String content = flagReportCacheModel.content;

        if ((content != null) && (content.length() == 0)) {
            flagReportCacheModel.content = null;
        }

        flagReportCacheModel.flagReason = getFlagReason();

        String flagReason = flagReportCacheModel.flagReason;

        if ((flagReason != null) && (flagReason.length() == 0)) {
            flagReportCacheModel.flagReason = null;
        }

        flagReportCacheModel.flagComment = getFlagComment();

        String flagComment = flagReportCacheModel.flagComment;

        if ((flagComment != null) && (flagComment.length() == 0)) {
            flagReportCacheModel.flagComment = null;
        }

        flagReportCacheModel.moderateAction = getModerateAction();

        String moderateAction = flagReportCacheModel.moderateAction;

        if ((moderateAction != null) && (moderateAction.length() == 0)) {
            flagReportCacheModel.moderateAction = null;
        }

        flagReportCacheModel.moderatorComment = getModeratorComment();

        String moderatorComment = flagReportCacheModel.moderatorComment;

        if ((moderatorComment != null) && (moderatorComment.length() == 0)) {
            flagReportCacheModel.moderatorComment = null;
        }

        flagReportCacheModel.status = getStatus();

        flagReportCacheModel.statusByUserId = getStatusByUserId();

        flagReportCacheModel.statusByUserName = getStatusByUserName();

        String statusByUserName = flagReportCacheModel.statusByUserName;

        if ((statusByUserName != null) && (statusByUserName.length() == 0)) {
            flagReportCacheModel.statusByUserName = null;
        }

        Date statusDate = getStatusDate();

        if (statusDate != null) {
            flagReportCacheModel.statusDate = statusDate.getTime();
        } else {
            flagReportCacheModel.statusDate = Long.MIN_VALUE;
        }

        return flagReportCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(37);

        sb.append("{uuid=");
        sb.append(getUuid());
        sb.append(", flagReportId=");
        sb.append(getFlagReportId());
        sb.append(", groupId=");
        sb.append(getGroupId());
        sb.append(", companyId=");
        sb.append(getCompanyId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", classNameId=");
        sb.append(getClassNameId());
        sb.append(", classPK=");
        sb.append(getClassPK());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", title=");
        sb.append(getTitle());
        sb.append(", content=");
        sb.append(getContent());
        sb.append(", flagReason=");
        sb.append(getFlagReason());
        sb.append(", flagComment=");
        sb.append(getFlagComment());
        sb.append(", moderateAction=");
        sb.append(getModerateAction());
        sb.append(", moderatorComment=");
        sb.append(getModeratorComment());
        sb.append(", status=");
        sb.append(getStatus());
        sb.append(", statusByUserId=");
        sb.append(getStatusByUserId());
        sb.append(", statusByUserName=");
        sb.append(getStatusByUserName());
        sb.append(", statusDate=");
        sb.append(getStatusDate());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(58);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.FlagReport");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>uuid</column-name><column-value><![CDATA[");
        sb.append(getUuid());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>flagReportId</column-name><column-value><![CDATA[");
        sb.append(getFlagReportId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>groupId</column-name><column-value><![CDATA[");
        sb.append(getGroupId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>companyId</column-name><column-value><![CDATA[");
        sb.append(getCompanyId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
        sb.append(getClassNameId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>classPK</column-name><column-value><![CDATA[");
        sb.append(getClassPK());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>title</column-name><column-value><![CDATA[");
        sb.append(getTitle());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>content</column-name><column-value><![CDATA[");
        sb.append(getContent());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>flagReason</column-name><column-value><![CDATA[");
        sb.append(getFlagReason());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>flagComment</column-name><column-value><![CDATA[");
        sb.append(getFlagComment());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>moderateAction</column-name><column-value><![CDATA[");
        sb.append(getModerateAction());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>moderatorComment</column-name><column-value><![CDATA[");
        sb.append(getModeratorComment());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>status</column-name><column-value><![CDATA[");
        sb.append(getStatus());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
        sb.append(getStatusByUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
        sb.append(getStatusByUserName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
        sb.append(getStatusDate());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
